package Operation;

import Book.Book;
import Book.BookList;
import jdk.dynalink.Operation;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mirac
 * Date: 2025-06-02
 * Time: 21:34
 */
public class FindOperation implements IOperation {
    public void work(BookList bookList) {
        System.out.println("1. 查找图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要找的图书的名字：");
        String name = scanner.nextLine();
        int sz = bookList.getBookSize();
        for (int i = 0; i < sz; i++) {
            if(bookList.getBook(i).getName().equals(name)) {
                System.out.println("找到了：");
                Book book = bookList.getBook(i);
                System.out.println(book);
                return;
            }

            System.out.println("没有你要找的图书。");
            return;
        }

    }
}
